#include <stdio.h>
#include <conio.h>
#define N 16

void main(){
		  clrscr();
			int i,j,rows,cols;
			int a[N][N],num,p=1;

  //The larger of the array
		   while(p==1){
					 printf("please input a number:");
					 scanf("%d",&num);
					 if(num%2!=0){p=0;}
					 }

			for(i=1;i<=num;i++)
			   for(j=1;j<=num;j++)
				   a[i][j]=0;

  //create a array
			rows=1;
			cols=(num+1)/2;
			a[rows][cols]=1;
			for(i=2;i<=(num*num);i++)
			   {
				--rows; ++cols;
				if(rows==0 && cols>num)
				  { rows+=2;
					cols--;}
				else
				  {
				   if(rows==0 && cols<=num){rows=num;}
				   if(rows!=0 && cols>num){cols=1;}
				  }

				if(a[rows][cols]!=0)
				  {rows+=2;
				   cols--;
				  }
				 a[rows][cols]=i;
				}

  //put out then array

			for(i=1;i<=num;i++){
			   for(j=1;j<=num;j++)
				  printf("  %d",a[i][j]);
				printf("\n");
				printf("\n");
			   }

		 while(!kbhit()){ }    //wait a keyboard

        }
